/**
 * 外部链接跳转详情页面
 */

import { queryURL } from "./common";

// 合同成本认定详情页面

const contractCostDetail = "contractBudgetIdentificationDetail";

const contractCostAutoDetail = "contractBudgetIdentificationAutoDetail";

// 订单详情页面
const orderDetail = "orderAddPage";

// 出入库详情页
const wareHouseManagementDetail = "wareHouseManagementAdd";

// 特殊付款详情页
const specialPaymentDetail = "specialPaymentPreProcessingDetail";

export const externalLink = (path: string, fromPath: string) => {
  const queryParams: any = queryURL("");
  if (queryParams.id && queryParams?.routerPath.includes("detail")) {
    if (path === "/orderManagement") {
      return {
        name: orderDetail,
        params: {
          orderNo: queryParams.id,
          type: "detail",
        },
      };
    } else if (path === "/wareHouseManagement") {
      return {
        name: wareHouseManagementDetail,
        params: {
          id: queryParams.id,
          type: "detail",
        },
      };
    } else if (path === "/contractBudgetIdentification") {
      return {
        name: queryParams.createType == 2 ? contractCostDetail : contractCostAutoDetail,
        params: {
          id: queryParams.id,
          type: "detail",
        },
      };
    }
  }
};
